package m.jclecai.com.activity;

import android.widget.RadioGroup;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;
import m.jclecai.com.R;
import m.jclecai.com.base.BaseActivity;
import m.jclecai.com.bean.TrendButtonBean;
import m.jclecai.com.fragment.HotTrendFragment;
import m.jclecai.com.fragment.LottoTrendFragment;
import m.jclecai.com.pop.MyTrendPopUpWindow;

/**
 * 走势图
 */
public class LottoTrendActivity extends BaseActivity {
    @BindView(R.id.rg_count)
    RadioGroup rgCount;

    LottoTrendFragment ltFragment;
    HotTrendFragment htFragment;

    @Override
    public int getContentView() {
        return R.layout.activity_lotto_trend;
    }

    int defCheck = R.id.rb_zs;
    int position=0;
    TrendButtonBean bean;

    @Override
    public void initView() {
        setTitle(getIntent().getStringExtra("title"));
        leftOptionText("");
        rightOptionText("走势");
    }

    @Override
    protected void initData() {
        super.initData();
        //走势图
        ltFragment = new LottoTrendFragment();
        Integer lotteryId = getIntent().getIntExtra("lotteryId",0);
        int i = idxs.indexOf(new TrendButtonBean(null,null,0,lotteryId,null,null,false,false,false,null,null,false));

        if(i != -1){
            position=i;
        }
        ltFragment.setTrendData(idxs.get(position));

        //冷热图
        htFragment = new HotTrendFragment();
        htFragment.setTrendData(idxs.get(position));
        repalce(ltFragment);
    }


    @Override
    public void initListener() {
        super.initListener();
        rgCount.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                switch (checkedId) {
                    case R.id.rb_30:
                        getCurrentFragment().loadData("30");
                        break;
                    case R.id.rb_50:
                        getCurrentFragment().loadData("50");
                        break;
                    case R.id.rb_100:
                        getCurrentFragment().loadData("100");
                        break;
                }
            }
        });
    }

    @OnClick(R.id.tv_right_option)
    void rightOption() {
        final MyTrendPopUpWindow mt = new MyTrendPopUpWindow(this, defCheck, idxs.get(position).isHasHot());
        mt.setListener(new MyTrendPopUpWindow.OnCheckListener() {
            @Override
            public void check(RadioGroup group, int checkedId) {
                defCheck = checkedId;
                if (checkedId == R.id.rb_zs) {
                    repalce(ltFragment);
                    setTitle("走势");
                    mt.dismiss();
                } else {
                    repalce(htFragment);
                    setTitle("冷热");
                    mt.dismiss();
                }
            }
        });
        mt.showAsDropDown(tvRightOption);
    }

    List<TrendButtonBean> idxs = new ArrayList<TrendButtonBean>(){{
        //超级大乐透
        add(
                new TrendButtonBean(new String[]{"红一区","红二区","红三区","后区"},
                        new String[]{"area1","area2","area3","back"},0,19,
                        new int[]{R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_blue},
                        new Boolean[]{false,false,false,false},true,false,true,
                        new String[]{"第一位","第二位","第三位","第四位","第五位","蓝球一","蓝球二"},
                        new String[]{"num_info1","num_info2","num_info3","num_info4","num_info5","num_info6","num_info7"},true

                ));
        //七星彩
        add(
                new TrendButtonBean(new String[]{"第七位","第六位","第五位","第四位","第三位","第二位","第一位"},
                        new String[]{"num_info7","num_info6","num_info5","num_info4","num_info3","num_info2","num_info1"},4,18
                        ,new int[]{R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red},
                        new Boolean[]{true,true,true,true,true,true,true},false,true,false,
                        new String[]{"第一位","第二位","第三位","第四位","第五位","第六位","第七位"},
                        new String[]{"num_info1","num_info2","num_info3","num_info4","num_info5","num_info6","num_info7"},true
                ));
        //排列三
        add(
                new TrendButtonBean(new String[]{"百位","十位","个位"},
                        new String[]{"num_info1","num_info2","num_info3"},0,2
                        ,new int[]{R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red},
                        new Boolean[]{true,true,true},false,true,false,
                        new String[]{"第一位","第二位","第三位"},
                        new String[]{"num_info1","num_info2","num_info3"},true
                ));
        //排列五
        add(
                new TrendButtonBean(new String[]{"万位","千位","百位","十位","个位"},
                        new String[]{"num_info1","num_info2","num_info3","num_info4","num_info5"},2,13
                        ,new int[]{R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red},
                        new Boolean[]{true,true,true,true,true},false,true,false,
                        new String[]{"百位","十位","个位"},
                        new String[]{"num_info3","num_info2","num_info1"},true
                ));
        //双色球
        add(
                new TrendButtonBean(new String[]{"红一区","红二区","红三区","蓝球"},
                        new String[]{"area1","area2","area3","num_info7"},0,16
                        ,new int[]{R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_blue},
                        new Boolean[]{false,false,false,true},true,false,false,
                        new String[]{"第一位","第二位","第三位","第四位","第五位","第六位","蓝球二"},
                        new String[]{"num_info1","num_info2","num_info3","num_info4","num_info5","num_info6","num_info7"},true
                )
        );
        //福彩3d
        add(
                new TrendButtonBean(new String[]{"百位","十位","个位"},
                        new String[]{"num_info1","num_info2","num_info3"},0,1
                        ,new int[]{R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red},
                        new Boolean[]{true,true,true},false,true,false,
                        new String[]{"百位","十位","个位"},
                        new String[]{"num_info3","num_info2","num_info1"},true
                )
        );
        //江西11选5
        add(
                new TrendButtonBean(new String[]{"万位","千位","百位","十位","个位"},
                        new String[]{"num_info1","num_info2","num_info3","num_info4","num_info5"},2,9
                        ,new int[]{R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red},
                        new Boolean[]{true,true,true,true,true},false,false,true,
                        new String[]{"第一位","第二位","第三位","第四位","第五位"},
                        new String[]{"num_info1","num_info2","num_info3","num_info4","num_info5"},true
                )
        );
        //11夺金
        add(
                new TrendButtonBean(new String[]{"万位","千位","百位","十位","个位"},
                        new String[]{"num_info1","num_info2","num_info3","num_info4","num_info5"},2,8
                        ,new int[]{R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red},
                        new Boolean[]{true,true,true,true,true},false,false,true,
                        new String[]{"第一位","第二位","第三位","第四位","第五位"},
                        new String[]{"num_info1","num_info2","num_info3","num_info4","num_info5"},true
                ));
        //广东11选五
        add(
                new TrendButtonBean(new String[]{"万位","千位","百位","十位","个位"},
                        new String[]{"num_info1","num_info2","num_info3","num_info4","num_info5"},2,10
                        ,new int[]{R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red},
                        new Boolean[]{true,true,true,true,true},false,false,true,
                        new String[]{"第一位","第二位","第三位","第四位","第五位"},
                        new String[]{"num_info1","num_info2","num_info3","num_info4","num_info5"},true
                ));
        //上海1选五
        add(
                new TrendButtonBean(new String[]{"万位","千位","百位","十位","个位"},
                        new String[]{"num_info1","num_info2","num_info3","num_info4","num_info5"},2,24
                        ,new int[]{R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red},
                        new Boolean[]{true,true,true,true,true},false,false,true,
                        new String[]{"第一位","第二位","第三位","第四位","第五位"},
                        new String[]{"num_info1","num_info2","num_info3","num_info4","num_info5"},true
                ));
        //黑龙江11选五
  /*      add(
                new TrendButtonBean(new String[]{"万位","千位","百位","十位","个位"},
                        new String[]{"num_info5","num_info4","num_info3","num_info2","num_info1"},2,25
                        ,new int[]{R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red},
                        new Boolean[]{true,true,true,true,true},false,false,true,
                        new String[]{"第一位","第二位","第三位","第四位","第五位"},
                        new String[]{"num_info1","num_info2","num_info3","num_info4","num_info5"},true
                ));*/
        //浙江11选五
        add(
                new TrendButtonBean(new String[]{"万位","千位","百位","十位","个位"},
                        new String[]{"num_info1","num_info2","num_info3","num_info4","num_info5"},2,27
                        ,new int[]{R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red},
                        new Boolean[]{true,true,true,true,true},false,false,true,
                        new String[]{"第一位","第二位","第三位","第四位","第五位"},
                        new String[]{"num_info1","num_info2","num_info3","num_info4","num_info5"},true
                ));
        //七乐彩
        add(
                new TrendButtonBean(new String[]{"一区","二区","三区"},
                        new String[]{"area1","area2","area3"},0,17
                        ,new int[]{R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red},
                        new Boolean[]{false,false,false},true,false,false,
                        new String[]{"第一位","第二位","第三位","第四位","第五位","第六位","第七位"},
                        new String[]{"num_info1","num_info2","num_info3","num_info4","num_info5","num_info6","num_info7"},true
                ));
        //重庆时时彩
        add(
                new TrendButtonBean(new String[]{"万位","千位","百位","十位","个位"},
                        new String[]{"num_info1","num_info2","num_info3","num_info4","num_info5"},2,3
                        ,new int[]{R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red},
                        new Boolean[]{true,true,true,true,true},false,true,false,
                        new String[]{"百位","十位","个位"},
                        new String[]{"num_info3","num_info2","num_info1"},true
                ));
        //胜负彩
        add(
                new TrendButtonBean(new String[]{"3","1","0"},
                        new String[]{"3","1","0"},0,71
                        ,new int[]{R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red},
                        new Boolean[]{true,true,true},false,false,false,null,null,false
                ));
        //安徽快三
        add(
                new TrendButtonBean(new String[]{"百位","十位","个位"},
                        new String[]{"num_info3","num_info2","num_info1"},0,32
                        ,new int[]{R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red},
                        new Boolean[]{true,true,true},false,false,false,
                        new String[]{"第一位","第二位","第三位"},
                        new String[]{"num_info1","num_info2","num_info3"},true)
        );
        //湖北快三
        add(
                new TrendButtonBean(new String[]{"百位","十位","个位"},
                        new String[]{"num_info3","num_info2","num_info1"},0,33
                        ,new int[]{R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red},
                        new Boolean[]{true,true,true},false,false,false,
                        new String[]{"第一位","第二位","第三位"},
                        new String[]{"num_info1","num_info2","num_info3"},true)
        );
        //吉林快三
        add(
                new TrendButtonBean(new String[]{"百位","十位","个位"},
                        new String[]{"num_info3","num_info2","num_info1"},0,34
                        ,new int[]{R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red},
                        new Boolean[]{true,true,true},false,false,false,
                        new String[]{"第一位","第二位","第三位"},
                        new String[]{"num_info1","num_info2","num_info3"},true)
        );
        //江苏快三
        add(
                new TrendButtonBean(new String[]{"百位","十位","个位"},
                        new String[]{"num_info3","num_info2","num_info1"},0,35
                        ,new int[]{R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red},
                        new Boolean[]{true,true,true},false,false,false,
                        new String[]{"第一位","第二位","第三位"},
                        new String[]{"num_info1","num_info2","num_info3"},true)
        );

        //江苏11选五
        add(
                new TrendButtonBean(new String[]{"万位","千位","百位","十位","个位"},
                        new String[]{"num_info5","num_info4","num_info3","num_info2","num_info1"},2,28
                        ,new int[]{R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red},
                        new Boolean[]{true,true,true,true,true},false,false,true,
                        new String[]{"第一位","第二位","第三位","第四位","第五位"},
                        new String[]{"num_info1","num_info2","num_info3","num_info4","num_info5"},true
                ));
        //浙江12选5
        add(
                new TrendButtonBean(new String[]{"万位","千位","百位","十位","个位"},
                        new String[]{"num_info5","num_info4","num_info3","num_info2","num_info1"},2,22
                        ,new int[]{R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red},
                        new Boolean[]{true,true,true,true,true},false,false,true,
                        new String[]{"第一位","第二位","第三位","第四位","第五位"},
                        new String[]{"num_info1","num_info2","num_info3","num_info4","num_info5"},true
                ));
        //湖北11选5
        add(
                new TrendButtonBean(new String[]{"万位","千位","百位","十位","个位"},
                        new String[]{"num_info5","num_info4","num_info3","num_info2","num_info1"},2,29
                        ,new int[]{R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red,R.color.trend_ball_red},
                        new Boolean[]{true,true,true,true,true},false,false,true,
                        new String[]{"第一位","第二位","第三位","第四位","第五位"},
                        new String[]{"num_info1","num_info2","num_info3","num_info4","num_info5"},true
                ));
    }};
}
